home *** CD-ROM | disk | FTP | other *** search
/ Nebula 1 / Nebula One.iso / Utilities / Converters / Convert_PICT / Source / CommentedPSCode / RCS / Regions,v < prev    next >
Encoding:
Text File  |  1995-06-12  |  13.2 KB  |  665 lines

  1. head     1.8;
  2. branch   ;
  3. access   ;
  4. symbols  beta10:1.7;
  5. locks    death:1.8;
  6. comment  @# @;
  7.  
  8.  
  9. 1.8
  10. date     93.04.04.23.31.06;  author death;  state Exp;
  11. branches ;
  12. next     1.7;
  13.  
  14. 1.7
  15. date     93.01.09.21.07.40;  author death;  state Exp;
  16. branches ;
  17. next     1.6;
  18.  
  19. 1.6
  20. date     93.01.01.11.51.45;  author death;  state Exp;
  21. branches ;
  22. next     1.5;
  23.  
  24. 1.5
  25. date     92.12.31.15.35.30;  author death;  state Exp;
  26. branches ;
  27. next     1.4;
  28.  
  29. 1.4
  30. date     92.12.05.23.07.44;  author death;  state Exp;
  31. branches ;
  32. next     1.3;
  33.  
  34. 1.3
  35. date     92.12.03.18.02.17;  author death;  state Exp;
  36. branches ;
  37. next     1.2;
  38.  
  39. 1.2
  40. date     92.11.27.19.38.23;  author death;  state Exp;
  41. branches ;
  42. next     1.1;
  43.  
  44. 1.1
  45. date     92.11.08.09.29.06;  author death;  state Exp;
  46. branches ;
  47. next     ;
  48.  
  49.  
  50. desc
  51. @@
  52.  
  53.  
  54. 1.8
  55. log
  56. @Sun Apr  4 23:31:05 PDT 1993
  57. @
  58. text
  59. @%BEGIN Regions
  60.  
  61. %%%%%%%%%%%%%
  62. %    Note:
  63. %        regionBounds and regionPath is defined in the common file
  64. %        regionInfo is top, left, bot, right coords of bounding rect, followed by the number
  65. %        of shapes.  Each spape is the number of vertices, followed by that many x,y pairs
  66. %        that represent the corners of the shape.
  67. %%%%%%%%%%%%%
  68.  
  69. %%%%%%%%%%%%%
  70. %    Name:    frameRgn            [0080]
  71. %    Syntax:    regionInfo frameRgn -
  72. %    About:    Set up bounds.  If pen sizes > 0 draw two paths.  The outer goes from passed
  73. %            vertex to passed vertex, drawing the outer edge.  The second is inset by the
  74. %            sizes of penWidth and penHeight.  Fill between these to get a frame of right size.
  75. %%%%%%%%%%%%%
  76. /frameRgn
  77. {
  78.     gsave
  79.         penPattern usePattern
  80.         /tempRight exch def
  81.         /tempBottom exch def
  82.         /tempLeft exch def
  83.         /tempTop exch def
  84.         /numShapes exch def
  85.         numShapes 0 eq
  86.         {
  87.             %
  88.             %    No shapes, frame the bounding rect.  (do this by building a
  89.             %    'fake' region shape for following routines to consume
  90.             %
  91.             tempLeft tempTop tempRight tempTop
  92.             tempRight tempBottom tempLeft  tempBottom
  93.             4
  94.             /numShapes 1 def
  95.         }
  96.         {
  97.             tempTop tempLeft tempBottom tempRight regionBounds
  98.             clip
  99.         }
  100.         ifelse
  101.  
  102.         penWidth 0 le
  103.         penHeight 0 le
  104.         or
  105.         {
  106.             %
  107.             %    Consume & discard coordinates, using the passed counts for the repeat
  108.             %
  109.             numShapes
  110.             {
  111.                 { pop pop }
  112.                 repeat
  113.             }
  114.             repeat
  115.         }
  116.         {
  117.             %
  118.             %    For each of the shapes, read in verticees and draw lines between
  119.             %    then, make a second pass over points, drawing inner path
  120.             %
  121.             newpath
  122.             numShapes
  123.             {
  124.                 /numCoords exch 2 mul def
  125.                 /ptArray  numCoords array def
  126.                 /firsty exch def
  127.                 /firstx exch def
  128.                 %
  129.                 %    Form the outer edge of shape, storing points in array
  130.                 %
  131.                 firstx firsty  moveto
  132.                 0 2 numCoords 3 sub    % 3 is for: zero origin, and skipped first coords
  133.                 {
  134.                     /arrayIndex exch def
  135.                     /y1 exch def
  136.                     /x1 exch def
  137.                     ptArray arrayIndex x1 put
  138.                     ptArray arrayIndex 1 add y1 put
  139.                     x1 y1 lineto
  140.                 }
  141.                 for
  142.                 closepath
  143.                 %
  144.                 %    Compute inner edge.  While inset by pen size, we must put vertices
  145.                 %    in non straightforward position.  lastx was the x coord of last vertex
  146.                 %    we saw.  thisx is the x of the current vertex.  pendx is the x coordinate
  147.                 %    that is proposed for the vertex to be drawn that cooresponds to the lastx
  148.                 %    This is because we can not definitely figure out where point N's inset
  149.                 %    coords are without knowing where point N+1 is.  Do a couple examples.
  150.                 %
  151.                 /pendx firstx penWidth add def
  152.                 /pendy firsty penHeight sub def
  153.                 /lastx ptArray 0 get   def
  154.                 /lasty ptArray 1 get  def
  155.                 pendx pendy  moveto
  156.                 2 4  numCoords 5 sub
  157.                 {
  158.                     /arrayIndex exch def
  159.  
  160.                     /thisx ptArray arrayIndex  get   def
  161.                     /thisy ptArray arrayIndex 1 add get  def
  162.                     %
  163.                     %    If thisy - lasty > 0, pendx = lastx + penWidth
  164.                     %
  165.                     /pendx lastx penWidth
  166.                         thisy lasty sub 0 gt {add}  {sub} ifelse
  167.                     def
  168.                     pendx pendy  lineto
  169.                     /lastx thisx def
  170.                     /lasty thisy def
  171.  
  172.                     /thisx ptArray arrayIndex 2 add get   def
  173.                     /thisy ptArray arrayIndex 3 add get  def
  174.                     /pendy lasty penHeight
  175.                         thisx lastx sub 0 gt {sub}  {add } ifelse
  176.                     def
  177.                     pendx pendy  lineto
  178.                     /lasty thisy def
  179.                     /lastx thisx def
  180.  
  181.                 }
  182.                 for
  183.                 firstx penWidth add pendy  lineto
  184.                 closepath
  185.             }
  186.             repeat
  187.             eofill
  188.         }
  189.         ifelse
  190.     grestore
  191. }
  192. def
  193.  
  194. %%%%%%%%%%%%%
  195. %    Name:    paintRgn            [0081]
  196. %    Syntax:    regionInfo paintRgn -
  197. %    About:    Fill the passed region with the pen pattern (use eofill because there
  198. %            may be shapes within shapes all drawn in same direction). Note:
  199. %            If there are no shapes, we just fill the 'bounding' rect.
  200. %%%%%%%%%%%%%
  201. /paintRgn
  202. {
  203.     gsave
  204.         penPattern usePattern
  205.         regionBounds
  206.         /numShapes exch def
  207.         numShapes 0 eq
  208.         { fill }
  209.         {
  210.             clip
  211.             numShapes  regionPath
  212.             eofill
  213.         }
  214.         ifelse
  215.     grestore
  216. }
  217. def
  218.  
  219. %%%%%%%%%%%%%
  220. %    Name:    eraseRgn            [0082]
  221. %    Syntax:    regionInfo eraseRgn -
  222. %    About:    Fill the passed region with the background pattern (use eofill because there
  223. %            may be shapes within shapes all drawn in same direction). Note:
  224. %            If there are no shapes, we just fill the 'bounding' rect.
  225. %%%%%%%%%%%%%
  226. /eraseRgn
  227. {
  228.     gsave
  229.         backPattern usePattern
  230.         regionBounds
  231.         /numShapes exch def
  232.         numShapes 0 eq
  233.         { fill }
  234.         {
  235.             clip
  236.             numShapes  regionPath
  237.             eofill
  238.         }
  239.         ifelse
  240.     grestore
  241. }
  242. def
  243.  
  244.  
  245. %%%%%%%%%%%%%
  246. %    Name:    invertRgn            [0083]
  247. %    Syntax:    regionInfo invertRgn -
  248. %    About:    Consume the region data.  No inversion because we can't easily.
  249. %%%%%%%%%%%%%
  250. /invertRgn
  251. {
  252.     gsave
  253.         regionBounds
  254.         regionPath
  255.     grestore
  256. } def
  257.  
  258. %%%%%%%%%%%%%
  259. %    Name:    fillRgn            [0084]
  260. %    Syntax:    regionInfo fillRgn -
  261. %    About:    Fill the passed region with the fill pattern (use eofill because there
  262. %            may be shapes within shapes all drawn in same direction). Note:
  263. %            If there are no shapes, we just fill the 'bounding' rect.
  264. %%%%%%%%%%%%%
  265. /fillRgn
  266. {
  267.     gsave
  268.         fillPattern usePattern
  269.         regionBounds
  270.         /numShapes exch def
  271.         numShapes 0 eq
  272.         { fill }
  273.         {
  274.             clip
  275.             numShapes  regionPath
  276.             eofill
  277.         }
  278.         ifelse
  279.     grestore
  280. }
  281. def
  282.  
  283. %%%%%%%%%%%%%
  284. %    Name:    frameSameRgn            [0088]
  285. %    Syntax:    - frameSameRgn -
  286. %    About:    Apple doesn't implement this, so nor do I
  287. %%%%%%%%%%%%%
  288. /frameSameRgn
  289.     { }
  290. def
  291.  
  292. %%%%%%%%%%%%%
  293. %    Name:    paintSameRgn            [0089]
  294. %    Syntax:    - paintSameRgn -
  295. %    About:    Apple doesn't implement this, so nor do I
  296. %%%%%%%%%%%%%
  297. /paintSameRgn
  298.     { }
  299. def
  300.  
  301. %%%%%%%%%%%%%
  302. %    Name:    eraseSameRgn            [008A]
  303. %    Syntax:    - eraseSameRgn -
  304. %    About:    Apple doesn't implement this, so nor do I
  305. %%%%%%%%%%%%%
  306. /eraseSameRgn
  307.     { }
  308. def
  309.  
  310. %%%%%%%%%%%%%
  311. %    Name:    invertSameRgn            [008B]
  312. %    Syntax:    - invertSameRgn -
  313. %    About:    Apple doesn't implement this, so nor do I
  314. %%%%%%%%%%%%%
  315. /invertSameRgn
  316.     { }
  317. def
  318.  
  319. %%%%%%%%%%%%%
  320. %    Name:    fillSameRgn            [008C]
  321. %    Syntax:    - fillSameRgn -
  322. %    About:    Apple doesn't implement this, so nor do I
  323. %%%%%%%%%%%%%
  324. /fillSameRgn
  325.     { }
  326. def
  327.  
  328. %END Regions
  329. @
  330.  
  331.  
  332. 1.7
  333. log
  334. @Sat Jan  9 21:07:40 PST 1993
  335. @
  336. text
  337. @@
  338.  
  339.  
  340. 1.6
  341. log
  342. @Fri Jan  1 11:51:45 PST 1993
  343. @
  344. text
  345. @@
  346.  
  347.  
  348. 1.5
  349. log
  350. @Thu Dec 31 15:35:30 PST 1992
  351. @
  352. text
  353. @@
  354.  
  355.  
  356. 1.4
  357. log
  358. @Sat Dec  5 23:07:44 PST 1992
  359. @
  360. text
  361. @d3 7
  362. a9 3
  363. %
  364. %    regionPath is defined in the common file
  365. %
  366. d11 7
  367. a17 21
  368. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  369. %    Opcode:    0080
  370. %    Name:    frameRgn
  371. %    Syntax:    - frameRgn -
  372. %    Description:
  373. %        Takes a region.  After setting up the bounds around the region, we check on the
  374. %        penwidth.  If it's zero, then we draw nothing and just consume all the vertices
  375. %        and their data.  Otherwise, for each shape, we draw lines as defined by the points
  376. %        that were written out. 
  377. %    Bugs:
  378. %        This used PICTline to frame the region, which is inaccurte, as the framing of
  379. %        a region does not hang down and to the right.
  380. %        A smarter way would be to keep track of whether we're drawing a left, right top
  381. %        or bottom side, and probably compensate appropriately with PICTline.  We can do
  382. %        this because the app always writes out the lines of a shape in a specific order, so it
  383. %        should be possible to keep track of what kinda line is about to be drawn.
  384. %        (it writes out the left coordinate of the first horozontal line, then the right, and
  385. %        then moves to rightline.  if it's up, then we want to extend to the right, if it's down
  386. %        then we want to extend to the left, since tis keeps the extending inside the shape.
  387. %        And so on.  Note that that will probably fail for shapes contained within others??
  388. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  389. d27 1
  390. a27 1
  391.         numShapes 0 gt
  392. a28 6
  393.             tempTop tempLeft tempBottom tempRight regionBounds
  394.             clip
  395.         }
  396.         {
  397.             tempTop tempLeft tempBottom tempRight regionBounds
  398.             clip
  399. d30 2
  400. a31 2
  401.             %    Construct a fake region so the following code will just parse this as if
  402.             %    it were notmal
  403. d38 4
  404. d43 4
  405. a46 3
  406.         penWidth 0 gt
  407.         penHeight 0 gt
  408.         and
  409. d49 1
  410. a49 2
  411.             %    Loop for each of the shapes, read in verticees and draw lines between.
  412.             %    be sure to draw the line between last and first point!
  413. d51 12
  414. d70 3
  415. d74 1
  416. a74 1
  417.                 0 2 numCoords 3 sub    % convert to 0 origin, and don't store firstx or y
  418. d77 5
  419. a81 5
  420.                     /y2 exch def
  421.                     /x2 exch def
  422.                     ptArray arrayIndex x2 put
  423.                     ptArray arrayIndex 1 add y2 put
  424.                     x2 y2 lineto
  425. d85 8
  426. a92 1
  427.  
  428. d104 3
  429. a129 1
  430.  
  431. a130 11
  432.         {
  433.             %
  434.             %    Consume the data, as the pen widht or height are 0.
  435.             %
  436.             numShapes
  437.             {
  438.                 { pop pop }
  439.                 repeat    % using the count of points stored on the stack
  440.             }
  441.             repeat
  442.         }
  443. d136 7
  444. a142 11
  445.  
  446. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  447. %    Opcode:    0081
  448. %    Name:    paintRgn
  449. %    Syntax:    - paintRgn -
  450. %    Description:
  451. %        Takes a region, builds a path, and then paints it with the paint pattern
  452. %        Use eofill because shapes inside others won't have opposite directions for
  453. %        their being drawn, necessarily.   Note that if there are 0 shapes, we simply
  454. %        fill the bounding rect.
  455. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  456. d161 7
  457. a167 11
  458.  
  459. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  460. %    Opcode:    0082
  461. %    Name:    eraseRgn
  462. %    Syntax:    - eraseRgn -
  463. %    Description:
  464. %        Takes a region, builds a path, and then erases it with the background pattern
  465. %        Use eofill because shapes inside others won't have opposite directions for
  466. %        their being drawn, necessarily.   Note that if there are 0 shapes, we simply
  467. %        fill the bounding rect.
  468. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  469. d187 5
  470. a191 9
  471. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  472. %    Opcode:    0083
  473. %    Name:    invertRgn
  474. %    Syntax:    - invertRgn -
  475. %    Description:
  476. %        Takes a Rgngon, builds a path, and then inverts it.  I haven't found
  477. %        any draw apps that actually use this so I can see what it actually does,
  478. %        so, I have little qualms about not even trying to implement it.
  479. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  480. d200 7
  481. a206 11
  482.  
  483. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  484. %    Opcode:    0084
  485. %    Name:    fillRgn
  486. %    Syntax:    - fillRgn -
  487. %    Description:
  488. %        Takes a region, builds a path, and then filles it with the fill pattern
  489. %        Use eofill because shapes inside others won't have opposite directions for
  490. %        their being drawn, necessarily.   Note that if there are 0 shapes, we simply
  491. %        fill the bounding rect.
  492. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  493. d225 2
  494. a226 4
  495.  
  496. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  497. %    Opcode:    0088
  498. %    Name:    frameSameRgn
  499. d228 2
  500. a229 3
  501. %    Description:
  502. %        This is not presently implemented by Apple, and thus it also does nothing here
  503. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  504. d234 2
  505. a235 4
  506.  
  507. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  508. %    Opcode:    0089
  509. %    Name:    paintSameRgn
  510. d237 2
  511. a238 3
  512. %    Description:
  513. %        This is not presently implemented by Apple, and thus it also does nothing here
  514. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  515. d243 2
  516. a244 4
  517.  
  518. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  519. %    Opcode:    008A
  520. %    Name:    eraseSameRgn
  521. d246 2
  522. a247 3
  523. %    Description:
  524. %        This is not presently implemented by Apple, and thus it also does nothing here
  525. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  526. d252 2
  527. a253 4
  528.  
  529. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  530. %    Opcode:    008B
  531. %    Name:    invertSameRgn
  532. d255 2
  533. a256 3
  534. %    Description:
  535. %        This is not presently implemented by Apple, and thus it also does nothing here
  536. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  537. d261 2
  538. a262 4
  539.  
  540. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  541. %    Opcode:    008C
  542. %    Name:    fillSameRgn
  543. d264 2
  544. a265 3
  545. %    Description:
  546. %        This is not presently implemented by Apple, and thus it also does nothing here
  547. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  548. @
  549.  
  550.  
  551. 1.3
  552. log
  553. @Thu Dec  3 18:02:16 PST 1992
  554. @
  555. text
  556. @d32 4
  557. a35 1
  558.         regionBounds
  559. d37 18
  560. a54 1
  561.         clip
  562. d63 1
  563. d66 2
  564. a67 1
  565.                 /numPoints exch def
  566. d70 2
  567. a71 3
  568.                 /x1 firstx def
  569.                 /y1 firsty def
  570.                 numPoints 1 sub
  571. d73 1
  572. d76 3
  573. a78 3
  574.                     x1 y1 x2 y2 PICTline
  575.                     /y1 y2 def
  576.                     /x1 x2 def
  577. d80 34
  578. a113 2
  579.                 repeat
  580.                 x1 y1 firstx firsty PICTline
  581. d116 2
  582. @
  583.  
  584.  
  585. 1.2
  586. log
  587. @Fri Nov 27 19:38:22 PST 1992
  588. @
  589. text
  590. @d12 4
  591. a15 1
  592. %        Takes a region, builds a path, and then strokes it.
  593. d17 10
  594. a26 4
  595. %        At the moment, regionPath ignores the region data.  But, this
  596. %        goes further and doesn't even use the penwidth or height when
  597. %%%%%  Note the bug that the mac doesn't deal with framing things in this way,.
  598. %        framwing whatever portion of the region that we frame...
  599. d33 1
  600. d35 3
  601. a37 2
  602.         /numShapes exch def
  603.         numShapes
  604. d39 5
  605. a43 6
  606.             /numPoints exch def
  607.             /firsty exch def
  608.             /firstx exch def
  609.             /x1 firstx def
  610.             /y1 firsty def
  611.             numPoints 1 sub
  612. d45 15
  613. a59 5
  614.                 /y2 exch def
  615.                 /x2 exch def
  616.                 x1 y1 x2 y2 PICTline
  617.                 /y1 y2 def
  618.                 /x1 x2 def
  619. a61 2
  620.             x1 y1 firstx firsty PICTline
  621.             closepath
  622. d63 12
  623. a74 1
  624.         repeat
  625. d85 4
  626. a88 1
  627. %        Takes a region, builds a path, and then erases it with the paint pattern
  628. d95 9
  629. a103 3
  630.         clip
  631.         regionPath
  632.         fill
  633. d115 3
  634. d124 9
  635. a132 3
  636.         clip
  637.         regionPath
  638.         fill
  639. d161 4
  640. a164 1
  641. %        Takes a Rgngon, builds a path, and then fills it with the fill pattern
  642. d171 9
  643. a179 3
  644.         clip
  645.         regionPath
  646.         fill
  647. @
  648.  
  649.  
  650. 1.1
  651. log
  652. @Sun Nov  8 09:29:06 PST 1992
  653. @
  654. text
  655. @d16 1
  656. d23 23
  657. a45 2
  658.         regionPath
  659.         stroke
  660. d62 2
  661. d82 2
  662. d103 1
  663. d120 2
  664. @
  665.